/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.WidgetsModel.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import uimigration.Interactions.DisplayValue;
import uimigration.WidgetsModel.Property;
import uimigration.WidgetsModel.WidgetsModelPackage;
import uimigration.uipositionning.Positionning;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Property</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.WidgetsModel.impl.PropertyImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.WidgetsModel.impl.PropertyImpl#getValue <em>Value</em>}</li>
 *   <li>{@link uimigration.WidgetsModel.impl.PropertyImpl#getDataType <em>Data Type</em>}</li>
 *   <li>{@link uimigration.WidgetsModel.impl.PropertyImpl#getPositionning <em>Positionning</em>}</li>
 *   <li>{@link uimigration.WidgetsModel.impl.PropertyImpl#getRenderingProperty <em>Rendering Property</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PropertyImpl extends EObjectImpl implements Property {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;
	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final String VALUE_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected String value = VALUE_EDEFAULT;
	/**
	 * The default value of the '{@link #getDataType() <em>Data Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDataType()
	 * @generated
	 * @ordered
	 */
	protected static final String DATA_TYPE_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getDataType() <em>Data Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDataType()
	 * @generated
	 * @ordered
	 */
	protected String dataType = DATA_TYPE_EDEFAULT;
	/**
	 * The cached value of the '{@link #getPositionningList() <em>Positionning</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPositionningList()
	 * @generated NOT
	 * @ordered
	 */
	protected EList<Positionning> positionning;
	/**
	 * The cached value of the '{@link #getRenderingProperty() <em>Rendering Property</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRenderingProperty()
	 * @generated
	 * @ordered
	 */
	protected DisplayValue renderingProperty;
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PropertyImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return WidgetsModelPackage.Literals.PROPERTY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetsModelPackage.PROPERTY__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(String newValue) {
		String oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetsModelPackage.PROPERTY__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDataType() {
		return dataType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDataType(String newDataType) {
		String oldDataType = dataType;
		dataType = newDataType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetsModelPackage.PROPERTY__DATA_TYPE, oldDataType, dataType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Positionning> getPositionning() {
		if (positionning == null) {
			positionning = new EObjectContainmentEList<Positionning>(Positionning.class, this, WidgetsModelPackage.PROPERTY__POSITIONNING);
		}
		return positionning;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DisplayValue getRenderingProperty() {
		return renderingProperty;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetRenderingProperty(DisplayValue newRenderingProperty, NotificationChain msgs) {
		DisplayValue oldRenderingProperty = renderingProperty;
		renderingProperty = newRenderingProperty;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY, oldRenderingProperty, newRenderingProperty);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRenderingProperty(DisplayValue newRenderingProperty) {
		if (newRenderingProperty != renderingProperty) {
			NotificationChain msgs = null;
			if (renderingProperty != null)
				msgs = ((InternalEObject)renderingProperty).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY, null, msgs);
			if (newRenderingProperty != null)
				msgs = ((InternalEObject)newRenderingProperty).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY, null, msgs);
			msgs = basicSetRenderingProperty(newRenderingProperty, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY, newRenderingProperty, newRenderingProperty));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
			case WidgetsModelPackage.PROPERTY__POSITIONNING:
				return ((InternalEList<?>)getPositionning()).basicRemove(otherEnd, msgs);
			case WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY:
				return basicSetRenderingProperty(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case WidgetsModelPackage.PROPERTY__NAME:
				return getName();
			case WidgetsModelPackage.PROPERTY__VALUE:
				return getValue();
			case WidgetsModelPackage.PROPERTY__DATA_TYPE:
				return getDataType();
			case WidgetsModelPackage.PROPERTY__POSITIONNING:
				return getPositionning();
			case WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY:
				return getRenderingProperty();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case WidgetsModelPackage.PROPERTY__NAME:
				setName((String)newValue);
				return;
			case WidgetsModelPackage.PROPERTY__VALUE:
				setValue((String)newValue);
				return;
			case WidgetsModelPackage.PROPERTY__DATA_TYPE:
				setDataType((String)newValue);
				return;
			case WidgetsModelPackage.PROPERTY__POSITIONNING:
				getPositionning().clear();
				getPositionning().addAll((Collection<? extends Positionning>)newValue);
				return;
			case WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY:
				setRenderingProperty((DisplayValue)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case WidgetsModelPackage.PROPERTY__NAME:
				setName(NAME_EDEFAULT);
				return;
			case WidgetsModelPackage.PROPERTY__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
			case WidgetsModelPackage.PROPERTY__DATA_TYPE:
				setDataType(DATA_TYPE_EDEFAULT);
				return;
			case WidgetsModelPackage.PROPERTY__POSITIONNING:
				getPositionning().clear();
				return;
			case WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY:
				setRenderingProperty((DisplayValue)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case WidgetsModelPackage.PROPERTY__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case WidgetsModelPackage.PROPERTY__VALUE:
				return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
			case WidgetsModelPackage.PROPERTY__DATA_TYPE:
				return DATA_TYPE_EDEFAULT == null ? dataType != null : !DATA_TYPE_EDEFAULT.equals(dataType);
			case WidgetsModelPackage.PROPERTY__POSITIONNING:
				return positionning != null && !positionning.isEmpty();
			case WidgetsModelPackage.PROPERTY__RENDERING_PROPERTY:
				return renderingProperty != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", value: ");
		result.append(value);
		result.append(", dataType: ");
		result.append(dataType);
		result.append(')');
		return result.toString();
	}

} //PropertyImpl
